package com.liu.jbase;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @date 2017年5月15日
 * @time 上午10:08:31
 * @author liuxingmi
 * @desc 分页
 * @param <T>
 */
public class PageListVo<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 第几页
     */
    private int currPage = 1;

    /**
     * 每页条数
     */
    private int pageSize = 10;

    /**
     * 总页数
     */
    private int pageCount;

    /**
     * 总数
     */
    private long total;

    /**
     * 结果对象
     */
    private List<T> rows = new ArrayList<T>();

    public PageListVo() {
    }

    public PageListVo(long total, List<T> datas) {
        this.total = total;
        this.rows = datas;
        this.pageCount = (((int) this.total - 1) / this.pageSize) + 1;
    }

    public PageListVo(long total, List<T> datas, int currPage, int pageSize) {
        
    	this.total = total;
        this.rows = datas;
        this.currPage = currPage;
        this.pageSize = pageSize;
        
        this.pageCount = (((int) this.total - 1) / pageSize) + 1;
        
    }

    public int getCurrPage() {
        return currPage;
    }

    public void setCurrPage(int currPage) {
        if (currPage <= 0) {
            this.currPage = 1;
        } else {
            this.currPage = currPage;
        }
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
        if (this.total > 0 && this.pageSize > 0 && this.pageCount == 0) {
            this.pageCount = (((int) this.total - 1) / this.pageSize) + 1;
        }
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

}
